<%@ page language="java" contentType="text/html; charset=utf-8" import="java.util.*,com.entity.*"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>用户列表</title>
<style type="text/css">
	table {
	border: 1px solid #0058a3; /* 表格边框 */
	font-family: Arial;
	border-collapse: collapse; /* 边框重叠 */
	background-color: #eaf5ff; /* 表格背景色 */
	font-size: 14px;
}



 th {
	background: #4bacff;
	border: 1px solid #0058a3;
	padding: 5px;
	width:100px;
}

 td {
	border: 1px solid #0058a3;
	padding: 5px;
}
span{
	margin: 10px;
}
</style>
</head>
<body>
	<table border="1">
		<tr>
			<th>id</th>
			<th>name</th>
			<th>password</th>
			<th>操作</th>
		</tr>
		
		
		<%--使用jstl标签库来遍历session中的users集合 --%>
		<%--users访问的范围顺序: page-->request-->session-->application --%>
		<c:forEach var="user" items="${users }">
			<%--user.xx是对应着user对象中的getXxx() --%>
			<tr>
				<td>${user.id }</td>
				<td>${user.name }</td>
				<td>${user.password }</td>
				<td><a href="DeleteUserServlet?userid=${user.id }">删除</a></td>
			</tr>
		</c:forEach>
	</table>
	<p>
		<span>${pc.currentPage }/${pc.totalPages}</span><span><a href="PrePageServlet?toPage=1">首页</a></span><span><a href="PrePageServlet?toPage=${pc.previousPage }">上一页</a></span><span><a href="PrePageServlet?toPage=${pc.nextPage}">下一页</a></span><span><a href="PrePageServlet?toPage=${pc.totalPages }">尾页</a></span>
		<span>
		<select id="toPageAction" onchange="changePage()">
			<c:forEach var="index" begin="1" end="${pc.totalPages }">
				<option value="${index }">${index}</option>
			</c:forEach>
		</select>
		</span>
	</p>
	<script type="text/javascript">
		function changePage(){
			var toPage = document.getElementById("toPageAction").value;
			window.location.href="PrePageServlet?toPage="+toPage;
		}
	</script>
</body>
</html>